﻿#ifndef WRWORKTCPCOMMHELPER_H
#define WRWORKTCPCOMMHELPER_H

#include "../WRSoft-Utility/WRBasics.h"

namespace WRWorkTcpComm
{
    //检查头部信息。
    inline WR32s checkHeader(const char* p, WR32s l)
    {
        WR32s i = 0;
        WR32s t = l - 3;
        while(i < t)
        {
            if (*p == 0)
            {
                if (p[1] == (char)0xFF && p[2] == 0 && p[3] == (char)0xAA)
                {
                    return i;
                }
            }
            ++p;
            ++i;
        }
        while(i < l)
        {
            if (*p == 0)
            {
                return i;
            }
            ++p;
            ++i;
        }
        return -1;
    }
}

#endif // WRWORKTCPCOMMHELPER_H
